using Client.Base;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.U2D;

namespace Client.Hotfix
{
    [SSM(SSMWeight.ResourceService)]
    public class ResourceService : IAwake, IDestroy
    {
        private ILoader loader;
        public void Awake(params object[] args)
        {
            loader = new YooAssetLoader();
            this.Log("[ Service ] - ResourceService is running...");
        }
        public async UniTask<SpriteAtlas> LoadAtlasSync(string location) => await loader.LoadAtlasSync(location);
        public async UniTask<TextAsset> LoadConfigSync(string location) => await loader.LoadConfigSync(location);
        public async UniTask<GameObject> LoadPrefabSync(string location) => await loader.LoadPrefabSync(location);
        public async UniTask<AudioClip> LoadSoundSync(string location) => await loader.LoadSoundSync(location);
        public async UniTask<Texture2D> LoadTexture2DSync(string location) => await loader.LoadTexture2DSync(location);
        public async UniTask<bool> LoadSceneSync(string location) => await loader.LoadSceneSync(location);
        public async UniTask<string> LoadVideoSync(string location) => await loader.LoadVideoSync(location);
        public void UnloadUnusedAssetsAsync() => loader.UnloadUnusedAssetsAsync();
        public void ReleaseAsset(string location) => loader.ReleaseAsset(location);

        public void Destroy()
        {
            loader?.Destroy();
        }
    }
}

